<p>This rule raises an issue when a ternary expression used with the spread operator in an array literal has branches with different types (array vs
string).</p>
<h2>Why is this an issue?</h2>
<p>When spreading a ternary expression in an array literal, using different types in the branches can make code harder to understand and maintain.</p>
<p>In JavaScript, both arrays and strings are iterable, so they can both be spread into arrays. However, mixing types creates inconsistency that can
confuse developers reading the code.</p>
<p>For example, <code>…​(condition ? [1, 2] : '')</code> works because an empty string spreads to nothing, but it’s not immediately clear to readers
that this is the intended behavior. Using <code>…​(condition ? [1, 2] : [])</code> makes the intent much clearer.</p>
<p>Consistent typing also makes the code more predictable. If you later need to modify one branch, you won’t accidentally introduce type-related bugs
by forgetting that the other branch expects a different type.</p>
<h3>What is the potential impact?</h3>
<p>This issue primarily affects code readability and maintainability. While it doesn’t cause runtime errors, it can lead to confusion during code
reviews and make future modifications more error-prone.</p>
<h3>How to fix?</h3>
<p>Use consistent types in both branches of the ternary. If one branch returns an array, make sure the other branch also returns an array (use an
empty array <code>[]</code> instead of an empty string).</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
const array = [
  a,
  ...(foo ? [b, c] : ''), // Noncompliant
];
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
const array = [
  a,
  ...(foo ? [b, c] : []),
];
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/consistent-empty-array-spread.md">consistent-empty-array-spread</a>
  </li>
  <li> MDN - Spread syntax - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax">Documentation about
  the spread operator in JavaScript</a> </li>
  <li> MDN - Conditional (ternary) operator - <a
  href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator">Documentation about ternary expressions in
  JavaScript</a> </li>
</ul>
